package com.chaofan.authsso.core.common;

import java.io.Serializable;

/**
 * Author: Chaofan
 * Date: 2020/6/5 14:31
 * email: chaofan2685@qq.com
 */
public class LocalCache implements Serializable {

    private static final long serialVersionUID = -3592550752073331616L;
    private long expiresTime = 0;

    private Object value;

    public LocalCache(long expiresTime, Object value) {
        this.expiresTime = System.currentTimeMillis()+(expiresTime*1000);
        this.value = value;
    }

    public LocalCache(Object value) {
        this.value = value;
    }

    public long getExpiresTime() {
        return expiresTime;
    }

    public void setExpiresTime(long expiresTime) {
        this.expiresTime = expiresTime;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public boolean isExpires(){
        if (expiresTime > 0){
            return System.currentTimeMillis()>expiresTime;
        }else {
            return false;
        }
    }

    public boolean isNotExpires(){
        if (expiresTime > 0){
            return System.currentTimeMillis()<expiresTime;
        }else {
            return true;
        }
    }
}
